package cn.raven._01_synchronize;

import org.apache.rocketmq.client.producer.DefaultMQProducer;
import org.apache.rocketmq.common.message.Message;

import java.nio.charset.StandardCharsets;

public class Producer {

    public static void main(String[] args) throws Exception {
        //创建生产者
        DefaultMQProducer producer = new DefaultMQProducer("my_producer_name");
        //设置nameserver
        producer.setNamesrvAddr("localhost:9876");
        //启动
        producer.start();
        //创建信息对象
        Message msg = new Message("jj", "bo", "jjking".getBytes(StandardCharsets.UTF_8));
        //发送消息
        producer.send(msg);
        //关闭
        producer.shutdown();
    }
}
